package com.zhp.dao.impl;

import com.zhp.dao.HtypeDao;
import com.zhp.pojo.HType;
import com.zhp.utils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @date 2023/4/11
 * @desc
 */
public class HtypeDaoImpl implements HtypeDao {

    QueryRunner queryRunner = new QueryRunner(DbUtils.getDataSource());

    @Override
    public List<HType> findAllTypes() {

        String sql = "select * from h_type";

        List<HType> query = null;
        try {
            query = queryRunner.query(sql, new BeanListHandler<>(HType.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return query;
    }
}
